import 'package:flutter_provider_demo/commons/http_client.dart';
import 'package:flutter_provider_demo/data/repositories/auth_repository.dart';
import 'package:flutter_provider_demo/data/repositories/cart_repository.dart';
import 'package:flutter_provider_demo/data/repositories/catalog_repository.dart';
import 'package:flutter_provider_demo/data/repositories/schedule_repository.dart';
import 'package:flutter_provider_demo/data/repositories/settings_repository.dart';
import 'package:flutter_provider_demo/data/services/api/auth_api_client.dart';
import 'package:flutter_provider_demo/data/services/api/catalog_api_client.dart';
import 'package:flutter_provider_demo/data/services/secure_storage.dart';
import 'package:flutter_provider_demo/data/services/shared_preference.dart';
import 'package:flutter_provider_demo/ui/catalog/catalog_viewmodel.dart';
import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';
import 'package:sqflite/sqflite.dart';

List<SingleChildWidget> providers(Database database) => [
      Provider(create: (_) => HttpClient()),
      Provider(create: (_) => SecureStorage()),
      Provider(create: (_) => SharedPreference()),
      Provider(create: (_) => AuthApiClient()),
      ChangeNotifierProvider(
        create: (context) => AuthRepository(
          authService: context.read(),
          secureStorage: context.read(),
          sharedPreference: context.read(),
        ),
      ),
      Provider(
        create: (context) => CatalogApiClient(httpClient: context.read()),
      ),
      // repository
      Provider(
        create: (context) => CatalogRepository(catalogApiClient: context.read()),
      ),
      Provider(
        create: (context) => ScheduelRepository(authRepository: context.read()),
      ),
      Provider(
        create: (context) => CartRepository(database: database),
      ),
      ChangeNotifierProvider(
        create: (context) => SettingsRepository(sharedPreference: context.read()),
      ),
      // viewmodel
      ChangeNotifierProvider(
        create: (context) => CatalogViewmodel(
          catalogRepository: context.read(),
          cartRepository: context.read(),
        ),
      ),
    ];
